`
https://leetcode.cn/problems/jump-game-ii/
`

/**
 * @param {number[]} nums
 * @return {number}
 */
var jump = function (nums) {
  const n = nums.length;
  let end = 0, farthest = 0;
  let jumps = 0;
  for (let i = 0; i < n - 1; i++) {
    farthest = Math.max(nums[i] + i, farthest);
    if (end === i) {
      jumps++;
      end = farthest;
    }
  }
  return jumps;
}